package ServiceImpl;

import java.util.List;

import Bean.Car;
import Bean.UserAndCar;
import Dao.User_CarDao;
import Service.UserCarService;

public class UserCarServiceImpl implements UserCarService {

	@Override
	public List<UserAndCar> selectAllCarOfUser(String username) {
		User_CarDao userCarDao = new User_CarDao();
		try {
			return userCarDao.selectAllCarOfUser(username);
		} catch(Exception e) {
			return null;
		}
	}

	@Override
	public boolean LinkCarToUser(String username, String car_id) {
		User_CarDao userCarDao = new User_CarDao();
		boolean ans = false;
		try {
			ans = userCarDao.contextUserAndCar(username, car_id);
		} catch(Exception e) {
			return false;
		}
		return ans;
	}

	@Override
	public List<UserAndCar> selectAllUserAndCarByCreateTime(String createTime) {
		User_CarDao userCarDao = new User_CarDao();
		try {
			return userCarDao.selectUserAndCarsByCreateTime(createTime);
		} catch(Exception e) {
			return null;
		}
	}

	@Override
	public UserAndCar selectOneUserAndCarByCarId(String car_id) {
		User_CarDao userCarDao = new User_CarDao();
		try {
			return userCarDao.selectOneCar(car_id);
		} catch(Exception e) {
			System.out.println("exception");
			return null;
		}
	}
}
